#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
	typedef vector<string> children;
	typedef string surname;
	
	map<surname, children> family;
	
	family["a"].push_back("a1");
	family["b"].push_back("b1");
	family["c"].push_back("c1");
	family["d"].push_back("d1");
	family["c"].push_back("c2");
	family["a"].push_back("a2");
	family["b"].push_back("b2");
	family["c"].push_back("c3");
	family["d"].push_back("d2");
	family["c"].push_back("c5");
	family["e"].push_back("e1");
	family["f"].push_back("f1");
	family["g"].push_back("g1");
	
	map<surname, children>::iterator mi;
	children::iterator vi;
	
	string s;
	
	for(mi = family.begin(); mi != family.end(); ++mi){
		s = mi->first;
		cout << s << endl;
		for(vi = mi->second.begin(); vi != mi->second.end(); ++vi)
			cout << s << "\t" << *vi << endl;
	}
	
	cout << "Please enter family name: ";
	string name;
	cin >> name;
	while(!name.empty()){
		cout << name << endl;
		for(vi = family[name].begin();
			vi != family[name].end(); ++vi){
			cout << name << "\t" << *vi << endl;
		}
		cout << "Please enter family name: ";
		cin >> name;
	}
	return 0;
}
